const readline = require('readline');
const fs = require('fs');

var socket = require('socket.io-client')('http://localhost:3000');
socket.on('connect', function () {
    var fileName = process.argv[2];
    const rl = readline.createInterface({
        input: fs.createReadStream(fileName)
    });
    var messages = [];
    rl.on('line', function (line) {
        var columns = line.split(',');
        messages.push(columns.join(' '));
    });
    var index = 0;
    setInterval(function () {
        socket.emit('record', messages[index++]);
        console.log(messages[index]);
    }, 100);
});
socket.on('event', function (data) {
});
socket.on('disconnect', function () {
});